<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" href="css/style.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<title>登录</title>
	</head>
	<body>
		
		<div id="bigBox">
			<h1>佩奇牧场后台管理</h1>
			
			<div class="inputBox">
				<div  class="inputText">
					<span class="iconfont icon-nickname"></span>
					<input id="form_username" type="text" placeholder="Username" />
				</div>
				<div class="inputText">
					<span class="iconfont icon-visible"></span>
					<input id="form_password" type="password" placeholder="Password" />
				</div>
				<button onclick="login()"  class="inputbutton">
					登录
					</button>
			</div>
		</div>
	</body>
	<script>
		function login(){
			var _password = $("#form_password").val();
			var _username = $("#form_username").val();
			// alert(_password)
			// let url = "/admin"
			// let data ={"username":_username,"password":_password}
			// console.log(data)
			// $.getJSON(url,data,function (result) {
			// 	console.log(result)
			// })
			$.ajax({
				type:'POST',
				url:"/admin/login",
				data:{"username":_username,"password":_password},
				dataType: "text",
				success:function(result){
					console.table(result);
						window.location.href = '/index.html';
				},
				error:function (){alert("用户名或密码错误")}
			})

		}
	</script>


</html>
